local liangzhu = fk.CreateSkill({
  name = "mini_mou__liangzhu",
})

Fk:loadTranslationTable{
  ["mini_mou__liangzhu"] = "良助",
  [":mini_mou__liangzhu"] = "出牌阶段限一次，你可以获得一名其他角色的一张手牌（此牌不计入手牌上限），然后你令你本阶段"..
  "发动〖结姻〗的目标选择一项：1.移动场上一张牌；2.摸两张牌。",

  ["#mini_mou__liangzhu0"] = "良助：获得一名角色的一张手牌",
  ["#mini_mou__liangzhu"] = "良助：获得一名角色的一张手牌，然后 %dest 选择一项",
  ["mini_mou__liangzhu_move"] = "移动场上一张牌",
  ["#mini_mou__liangzhu-move"] = "良助：请移动场上一张牌",

  ["$mini_mou__liangzhu1"] = "助君得胜战，跃马提缨枪！",
  ["$mini_mou__liangzhu2"] = "平贼成君业，何惜上沙场！",
}

liangzhu:addEffect("active", {
  anim_type = "control",
  prompt = function (self, player)
    if player:getMark("mini_mou__jieyin-phase") == 0 then
      return "#mini_mou__liangzhu0"
    else
      return "#mini_mou__liangzhu::"..player:getMark("mini_mou__jieyin-phase")
    end
  end,
  card_num = 0,
  target_num = 1,
  can_use = function(self, player)
    return player:usedSkillTimes(liangzhu.name, Player.HistoryPhase) == 0
  end,
  card_filter = function() return false end,
  target_filter = function(self, player, to_select, selected)
    return #selected == 0 and to_select ~= player and not to_select:isKongcheng()
  end,
  on_use = function(self, room, effect)
    local player = effect.from
    local target = effect.tos[1]
    local id = room:askToChooseCard(player, {
      target = target,
      flag = "h",
      skill_name = liangzhu.name,
    })
    room:moveCardTo(id, Card.PlayerHand, player, fk.ReasonPrey, liangzhu.name, nil, false, player, "mini_mou__liangzhu-inhand")
    local mark = player:getMark("mini_mou__jieyin-phase")
    if mark ~= 0 then
      local to = room:getPlayerById(mark)
      if to.dead then return end
      local choices = {"draw2"}
      if #room:canMoveCardInBoard() > 0 then
        table.insert(choices, 1, "mini_mou__liangzhu_move")
      end
      local choice = room:askToChoice(to, {
        choices = choices,
        skill_name = liangzhu.name,
      })
      if choice == "draw2" then
        room:drawCards(to, 2, liangzhu.name)
      else
        local targets = room:askToChooseToMoveCardInBoard(to, {
          skill_name = liangzhu.name,
          cancelable = false,
        })
        room:askToMoveCardInBoard(to, {
          target_one = targets[1],
          target_two = targets[2],
          skill_name = liangzhu.name,
        } )
      end
    end
  end,
})

liangzhu:addEffect("maxcards", {
  exclude_from = function (self, player, card)
    return card:getMark("mini_mou__liangzhu-inhand") > 0
  end,
})

return liangzhu
